<template>
  <div>
    <el-card
      shadow="never"
      body-style="padding: 20px;"
      class="type-info"
      style="height: 270px"
    >
      <ul v-if="assetType === 'web'">
        <li v-for="(item, key, index) in typeInfo" :key="'type' + key">
          <p class="type-name">{{ typeItem[index] }}</p>
          <p v-if="key !== 'update_time'">{{ item }}</p>
          <p v-else>{{ item | moment }}</p>
        </li>
      </ul>
      <ul v-if="assetType === 'os'">
        <li v-for="(item, key, index) in typeInfo" :key="'type' + key">
          <p class="type-name">{{ typeItem[index] }}</p>
          <p v-if="key !== 'update_time'">{{ item }}</p>
          <p v-else>{{ item | moment }}</p>
        </li>
      </ul>
      <span class="type-edit" @click="editTypeInfo">编辑>></span>
    </el-card>
    <el-dialog
      title="提示"
      :close-on-click-modal="false"
      :visible.sync="dialogVisible"
      width="600px"
    >
      <el-form
        v-if="itemType === 'web'"
        ref="editForm"
        :model="editForm"
        :rules="editRules"
        label-width="82px"
        @submit.native.prevent
      >
        <el-form-item label="域名地址:" prop="key">
          <el-input
            v-model="editForm.name"
            placeholder="请输入资产名称"
            clearable
          />
        </el-form-item>
        <el-form-item label="中间件:" prop="middleware">
          <el-input
            v-model="editForm.key"
            placeholder="请输入资产标识"
            clearable
          />
        </el-form-item>
        <el-form-item label="资产类型:" prop="middleware_vesion">
          <el-select
            v-model="editForm.type"
            placeholder="请选择资产类型"
            style="width: 100%"
          >
            <el-option
              v-for="(item, key) in assetType"
              :key="'type' + key"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="资产权重:" prop="name">
          <el-input
            v-model="editForm.value"
            value="1"
            min="1"
            placeholder="请输入资产权重"
            clearable
            type="number"
          />
        </el-form-item>
        <el-form-item label="资产描述:">
          <el-input
            v-model="editForm.description"
            placeholder="请输入资产描述"
            :rows="4"
            type="textarea"
          />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="closeModel">取 消</el-button>
        <el-button type="primary" @click="updateAssetType">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'AssetType'
}
</script>

<style lang="scss" scoped>

</style>
